Skip to content

Server side stream cursor - #48

Open
GrigorySmirnovSpb wants to merge 5 commits into
ydb-platform:mainfrom
GrigorySmirnovSpb:server-side_cursor
Open

GrigorySmirnovSpb wants to merge 5 commits into
ydb-platform:mainfrom
GrigorySmirnovSpb:server-side_cursor

Conversation

@GrigorySmirnovSpb

Copy link
Copy Markdown

Added a stream cursor, included a test for memory usage, and added a new configuration for actions.

@vgvoleg
vgvoleg requested a balanced review from Copilot October 27, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread CHANGELOG.md Resolved
Comment thread ydb_dbapi/connections.py Resolved
Comment thread ydb_dbapi/cursors.py Resolved
Comment thread ydb_dbapi/cursors.py Resolved
Comment thread ydb_dbapi/cursors.py Resolved
Comment thread ydb_dbapi/cursors.py
Comment on lines +458 to +460
def _register_current_cursor(self) -> None:
if self._tx_context is not None:
self._connection._set_current_cursor(self)
Comment thread ydb_dbapi/cursors.py Resolved
Comment thread ydb_dbapi/cursors.py Resolved
Comment thread CHANGELOG.md Outdated
@@ -1,3 +1,8 @@
## 0.1.25 ##

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to add a version here, it will be added by release workflow

Comment thread poetry.lock Outdated
@@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand.
# This file is automatically @generated by Poetry 2.5.1 and should not be changed by hand.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any changes in dependencies, why should you update lockfile?

Comment thread tests/test_cursors.py Outdated
await greenlet_spawn(self._test_cursor_state_after_error, async_cursor)


class FakeResultSet:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use mocks instead of 200 lines of “fake” objects? This code is copied directly from the SDK, so if the SDK implementation changes, these tests may no longer verify its actual behavior.

@GrigorySmirnovSpb

Copy link
Copy Markdown
Author

Not yet implemented: Track autocommit streams during connection shutdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread ydb_dbapi/cursors.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active critical and moderate findings remain: async cleanup can skip rollback and resource release on cursor-close failure, while unwrapped cleanup errors can leak raw YDB exceptions and leave cursors running.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Sync stream close leaks raw errors and may leave cursor running

ydb_dbapi/​cursors.py:669

Unlike the other public query paths, this new close() performs YDB operations (cancel, delete, and pool release) without handle_ydb_errors. A session cleanup failure therefore leaks a raw ydb.Error to callers instead of the DB-API error hierarchy, and can leave the cursor in running state because the final state cleanup is skipped. Translate cleanup errors while guaranteeing the cursor is unregistered and closed.

This issue also appears on line 1198 of the same file.

3 resolved since last review

Review effort: Lite

Comment thread ydb_dbapi/connections.py
Comment on lines +621 to +625
for cursor in list(self._active_stream_cursors):
await cursor.close()
self._active_stream_cursors.clear()
if self._current_cursor is not None:
await self._current_cursor.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants